<?php include("includes/session.php"); ?>
<?php include("includes/connect_db.php"); ?>
<?php include("includes/header.php"); ?>
<?php include("notif.php"); ?>

<style>
	#text-nama, #text-nama:focus{
		border: none;
		box-shadow: none;
		margin-top: 5px;
	}
	.row-fluid{
		min-height: 10px;
	}
	.pos2{
		padding: 5px 15px;
		background-color: #0088cc; 
		color: #FFF;
		margin-left: 5px;
		float: left;
		vertical-align: center;
		border-radius: 5px;
	}
	.isi_pesan{
		width: 99%; 
		height: 200px; 
		overflow: hidden; 
		word-wrap: break-word; 
		resize: none;
	}
	.close{
		color: #FFF;
	}
	.filterAll{
		padding: 5px;
		color: #FFF;
		cursor: pointer;
	}
	.kotakFilter{
		border: 1px solid #08c;
		border-radius: 3px;
	}
	.filterAll:hover{
		background: #08c;
	}
	.isiFilter{
		padding: 5px;
	}
	.filter{
		width: 100px;
	}
	.btn{
		width: 100px;
	}
	.btnFilter{
		background-color: #08c;
	}
</style>

<?php
	$sql_lihat_host_akademik = "SELECT * FROM tb_host WHERE db = 'db_seo_akademik'";
	$query_lihat_host_akademik = mysql_query($sql_lihat_host_akademik);
	$lihat_host_akademik = mysql_fetch_array($query_lihat_host_akademik);

	$konMhs = mysqli_connect($lihat_host_akademik['host'], $lihat_host_akademik['username'], $lihat_host_akademik['password']) or die("Connection Error: " . mysqli_error());
	mysqli_select_db($konMhs, $lihat_host_akademik['db']) or die("Error conecting to db.");

	$sql_lihat_host_pegawai = "SELECT * FROM tb_host WHERE db = 'db_seo_kepegawaian'";
	$query_lihat_host_pegawai = mysql_query($sql_lihat_host_pegawai);
	$lihat_host_pegawai = mysql_fetch_array($query_lihat_host_pegawai);

	$konPeg = mysqli_connect($lihat_host_pegawai['host'], $lihat_host_pegawai['username'], $lihat_host_pegawai['password']) or die("Connection Error: " . mysqli_error());
	mysqli_select_db($konPeg, $lihat_host_pegawai['db']) or die("Error conecting to db.");
?>

<div class="span9">  
    <h3>SMS</h3>                      
    <ul class="breadcrumb well">
        <li class="active">Broadcast</li>                
    </ul>    
    <h4>Buat Pesan Baru</h4>
    <div style="width: 100%">
		<div class="row-fluid">
			<div class="span6 kotakFilter">
				<div class="filterAll btnFilter">
					<span class="checkFilter">
						<input type="checkbox" value="mahasiswa" class="checkReal" style="display: none;">
	                    <i class="icon-check check icon-white" style="opacity: 0.4"></i>
					</span>
					<span style="margin-left: 10px;">
						Mahasiswa
					</span>
					<input type="hidden" value="0" class="cek">
				</div>
				<div class="isiFilter" style="display:none">
					<div>
						<span>
							<input type="checkbox" value="status" class="checkReal" style="display: none;">
		                    <i class="icon-check check" style="opacity: 0.2"></i>
						</span>
						<span style="margin-left: 10px;">
							Status
						</span>
						<span style="margin-left: 10px;">
							<select class="filter" name="status">
								<option name="status" value="1">
									Aktif
								</option>
								<option name="status" value="2">
									Cuti
								</option>
							</select>
						</span>
					</div>
					<div>
						<span>
							<input type="checkbox" value="angkatan" class="checkReal" style="display: none;">
		                    <i class="icon-check check" style="opacity: 0.2"></i>
						</span>
						<span style="margin-left: 10px;">
							Angkatan
						</span>
						<span style="margin-left: 10px;">
							<select class="filter" name="angkatan">
								<?php
									$sql_ambil_data = "SELECT * FROM tb_angkatan";
									$query_ambil_data = mysqli_multi_query($konMhs, $sql_ambil_data);
									$ambil_data = mysqli_store_result($konMhs);
									while ($data = mysqli_fetch_array($ambil_data)) {
										echo "<option name='angkatan' value='$data[id_angkatan]'>";
											echo $data['angkatan'];
										echo "</option>";
									}
								?>
							</select>
						</span>
					</div>
					<div>
						<span>
							<input type="checkbox" value="mk" class="checkReal" style="display: none;">
		                    <i class="icon-check check" style="opacity: 0.2"></i>
						</span>
						<span style="margin-left: 10px;">
							Mata Kuliah
						</span>
						<span style="margin-left: 10px;">
							<select class="filter" name="mk" style="width: auto;">
								<?php
									$sql = "SELECT * FROM tb_mk_penawaran WHERE id_periode = (SELECT id_periode FROM tb_periode WHERE STATUS = 1)";
									$query = mysqli_multi_query($konMhs, $sql);
									$data = mysqli_store_result($konMhs);
									while ($result = mysqli_fetch_array($data)) {
										$sqlMk = "SELECT * FROM tb_mk WHERE id_mk = $result[id_mk]";
										$queryMk = mysqli_multi_query($konMhs, $sqlMk);
										$data2 = mysqli_store_result($konMhs);
										$mk = mysqli_fetch_array($data2);
										echo "<option name='agama' value='$mk[id_mk]'>";
											echo $mk['nama'];
										echo "</option>";
									}
								?>
							</select>
						</span>
					</div>
					<div>
						<span>
							<input type="checkbox" value="agama" class="checkReal" style="display: none;">
		                    <i class="icon-check check" style="opacity: 0.2"></i>
						</span>
						<span style="margin-left: 10px;">
							Agama
						</span>
						<span style="margin-left: 10px;">
							<select class="filter" name="agama">
								<?php
									$sql_ambil_data = "SELECT * FROM tb_master_agama";
									$query_ambil_data = mysqli_multi_query($konMhs, $sql_ambil_data);
									$ambil_data = mysqli_store_result($konMhs);
									while ($data = mysqli_fetch_array($ambil_data)) {
										echo "<option name='agama' value='$data[id_master_agama]'>";
											echo $data['agama'];
										echo "</option>";
									}
								?>
							</select>
						</span>
					</div>
				</div>
			</div>
			<div class="span6 kotakFilter">
				<div class="filterAll btnFilter">
					<span class="checkFilter">
						<input type="checkbox" value="pegawai" class="checkReal" style="display: none;">
	                    <i class="icon-check check icon-white" style="opacity: 0.4"></i>
					</span>
					<span style="margin-left: 10px;">
						Pegawai
					</span>
					<input type="hidden" value="0" class="cek">
				</div>
				<div class="isiFilter" style="display:none">
					<div>
						<span>
							<input type="checkbox" value="entitas" class="checkReal" style="display: none;">
		                    <i class="icon-check check" style="opacity: 0.2"></i>
						</span>
						<span style="margin-left: 10px;">
							Entitas
						</span>
						<span style="margin-left: 10px;">
							<select class="filter" name="entitas">
								<option name="entitas" value="0">Dosen</option>
								<option name="entitas" value="1">Pegawai</option>
							</select>
						</span>
					</div>
					<div>
						<span>
							<input type="checkbox" value="status" class="checkReal" style="display: none;">
		                    <i class="icon-check check" style="opacity: 0.2"></i>
						</span>
						<span style="margin-left: 10px;">
							Status
						</span>
						<span style="margin-left: 10px;">
							<select class="filter" name="status">
								<?php
									$sql_ambil_data = "SELECT * FROM tb_master_status_pegawai";
									$query_ambil_data = mysqli_multi_query($konPeg, $sql_ambil_data);
									$ambil_data = mysqli_store_result($konPeg);
									while ($data = mysqli_fetch_array($ambil_data)) {
										echo "<option name='status' value='$data[id_master_status_pegawai]'>";
											echo $data['nama_status'];
										echo "</option>";
									}
								?>
							</select>
						</span>
					</div>

				</div>
			</div>
		</div>

		<div><b>Pesan</b></div>
		<div class="control-group">
			<textarea name="pesan" class="isi_pesan"><?php echo $pesan ?></textarea>
		</div>
		<div class="control-group">
			<div class="controls">
				<button type="submit" class="btn btn-info" id="kirim">
					<i class="icon-white icon-ok"></i>
					Kirim
				</button>
				<button type="submit" class="btn" id="simpan">
					<i class="icon-download-alt"></i>
					Simpan
				</button>
				<button type="submit" class="btn btn-danger" id="batal">
					<i class="icon-white icon-remove"></i>
					Batal
				</button>
			</div>
		</div>
	</div>

<?php
	
?>
    	

</div><!--/span-->

<?php include("includes/footer.php"); ?>

<script type="text/javascript">
    $(document).ready(function() {
    	$('.btnFilter').live('click', function(){
    		if ($(this).find('.checkReal').is(':checked')) {
    			
    		} else{
	    		if ($(this).find('.cek').val() == 0) {
	    			$(this).parent('div').find('.isiFilter').slideDown();
	    			$(this).find('.cek').val('1');
	    		} else{
	    			$(this).parent('div').find('.isiFilter').slideUp();
	    			$(this).find('.cek').val('0');
	    		}
	    	}
			return false;
    	});

    	$('.check').live('click', function(){
    		if($(this).parent('span').find('.checkReal').is(':checked')){
    			$(this).parent('span').find('.checkReal').removeAttr('checked');
				$(this).css('opacity', '0.4');
    		} else {
				$(this).parent('span').find('.checkReal').attr('checked', 'checked');
    			$(this).css('opacity', '1');
    			$(this).parent('span').parent('div').parent('div').find('.isiFilter').slideUp();
    			return false;
    		}
    	});

    	$('#kirim').click(function(){
    		if ($('.isi_pesan').val() == "") {
    			alert("isi Pesan Terlebih Dahulu");
    			window.location = "broadcast.php";
    		} else {
    			alert("Pesan Telah Berhasil Dikirim");
    			window.location = "broadcast.php";
    		};
    	});

    	$('#simpan').click(function(){
    		alert("Pesan Telah Disimpan");
    		window.location = "broadcast.php";
    	});
    });
</script>